const gulp = require('gulp')
const nodemon = require('gulp-nodemon')

var jsScript = 'node'
if (process.env.npm_config_argv !== undefined && process.env.npm_config_argv.indexOf('debug') > 0) {
    jsScript = 'node debug'
}

console.log(process.env.npm_config_argv)

gulp.task('nodemon', function () {
    return nodemon({
        script: 'build/server.js',
        execMap: {
            js: jsScript
        },
        verbose: true,
        ignore: ['build/*.js', 'dist/*.js', 'nodemon.json', '.git', 'node_modules/**/node_modules', 'gulpfile.js'],
        env: {
            NODE_ENV: 'development'
        },
        ext: 'js json'
    })
})

gulp.task('default', ['nodemon'], () => {
    console.log('gulpfile.js 已经运行!')
})
